package org.renhj.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import org.renhj.common.RpcResponse;
import org.renhj.metric.ZookeeperMetric;

public class RpcConsumerHandler extends SimpleChannelInboundHandler<RpcResponse> {

    @Override
    protected void messageReceived(ChannelHandlerContext channelHandlerContext, RpcResponse response) throws Exception {
        // 计算并更新最后一次请求的响应时间和系统时间
        ZookeeperMetric.getInstance().updateMetric(response.getRequestId(), System.currentTimeMillis());
        System.out.println("请求ID: " + response.getRequestId() + " 请求结果: " + response.getResult());
    }


}
